a = [
    {"m": "61569", "n": "北京南-天津南", "p": "18:06", "q": "18:39", "w": "00:33"},
    {"m": "61567", "n": "北京南-天津南", "p": "18:15", "q": "18:49", "w": "00:34"},
    {"m": "68917", "n": "北京南-天津西", "p": "18:20", "q": "19:19", "w": "00:59"},
    {"m": "6283", "n": "北京南-天津南", "p": "18:35", "q": "19:09", "w": "00:34"}
]

print(f"{'车次':<10}{'出发站-到达站':<20}{'出发时间':<10}{'到达时间':<10}{'历时':<6}")
print("-" * 50)

for a1 in a:
    print(f"{a1['m']:<10}{a1['n']:<20}{a1['p']:<10}{a1['q']:<10}{a1['w']:<6}")

b = input("请输入要购买的车次: ")
c = input("请输入乘车人，如果是多位乘车人使用逗号分隔: ")

d = False
for a1 in a:
    if a1['m'] == b:
        d = True
        break

if d:
    e = c.split(',')
    f = ', '.join(e)
    print(f"您已购买了{b} {a1['n']} {a1['p']}开, 请{f}尽快换取纸质车票。【铁路客服】")
else:
    print("该车次不存在，请重新输入。")